package com.okwanshiwu.controller;

import com.okwanshiwu.pojo.User;
import com.okwanshiwu.service.interfaces.AppUserService;
import com.okwanshiwu.util.PageData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;

/**
 * 开放权限的页面
 *
 * @author
 * @create 2017-07-28 16:58
 **/
@RestController
@RequestMapping("/noauth")
public class UserController extends BaseController{

	@Autowired
	private AppUserService appUser;

	/**
	 * 登录操作
	 * @return
	 */
	@RequestMapping(value = "/login",method = RequestMethod.POST)
	public String login(){
		PageData pd = this.getPageData();
		String sign = pd.get("sign")+"";
		if(!pd.containsKey("sign")){
			return "参数错误";
		}
		pd.remove("sign");
		TreeMap treeMap = new TreeMap();
		treeMap.putAll(pd);
		Iterator<Map.Entry<String,String>> it = treeMap.entrySet().iterator();
		while (it.hasNext()){
			Map.Entry<String,String> entry = it.next();
			String key = entry.getKey();
			String value = entry.getValue();
		}
		return "";
	}

	/**
	 * 注册操作
	 * @return
	 */
	@RequestMapping(value = "/register",method = RequestMethod.POST)
	public String register(User user){
		logger.debug(user.getDevice());
		PageData pd = this.getPageData();
		appUser.register();
		return "hahah";
	}

	/**
	 * 退出操作
	 * @return
	 */
	@RequestMapping(value = "/logout",method = RequestMethod.POST)
	public String logout(){
		return "";
	}

}
